import request from "@/utils/request";
import mockRequest from "@/utils/mockRequest";
import '@/mock';
//获取三级分类数据
export const reqCategoryList = ()=>{
    return request.get('/product/getBaseCategoryList');
}
//首页轮播的接口
export const reqBannerList = ()=>{
    return mockRequest.get("/bannerList");
}
//首页楼层的接口
export const reqFloorList = ()=>{
    return mockRequest.get("/floorList");
}

//search接口
export const reqSearchInfo = (searchParams = {}) => { // 注意: 传参所有参数都不是必传的,但是必须有一个空对象
    return request({

        url: '/list',
        method: 'post',
        data: searchParams
    })
}
//获取信息详情信息
export const reqGoodsDetailInfo = (skuId)=>{
    return request.get('/item/'+skuId)
}
//添加购物车接口
export const addToCart = (skuId, skuNum) => {
    return request.post(`/cart/addToCart/${ skuId }/${ skuNum }`)
}
//获取购物车列表
export const reqCartList = ()=>{
    return request.get(`/cart/cartList`);
};

// 购物车商品选中接口
export const reqCheckCart = (skuId, isChecked) => {
    return request.get(`/cart/checkCart/${ skuId }/${ isChecked }`)
}
// 删除购物车商品
export const reqDeleteCart = (skuId) => {
    return request.delete(`/cart/deleteCart/${ skuId }`)
}
// 全部选中接口
// post  /api/cart/batchCheckCart/{isChecked}
// 批量选中购物车
// 参数     skuIdList  数组  代表修改的商品id列表  请求体参数
//          isChecked  要修改的状态   1代表选中  0代表未选中
export const reqBatchCheckCart = (isChecked, skuIdList) => {
    return request.post(`/cart/batchCheckCart/${ isChecked }`, skuIdList);
}
// 购物车商品 - 批量删除
// POST /api/cart/batchDeleteCart
// 参数: skuIdList  数组  代表修改的商品id列表 请求体参数
export const reqBatchDeleteCart = (skuIdList) => {
    return request.post(`/cart/batchDeleteCart`, skuIdList)
}
// 获取验证码
// /api/user/passport/sendCode/{phone}
export const reqSendCode = (phone) => {
    return request.get(`/user/passport/sendCode/${ phone }`)
}
// 用户注册
// /api/user/passport/register
export const reqRegister = (data) => {
    return request.post(`/user/passport/register`, data)
}
// 登录
// /api/user/passport/login
export const reqLogin = (data) => {
    return request.post(`/user/passport/login`, data);
}
// 获取用户信息
// /api/user/passport/auth/getUserInfo
export const reqUserInfo = () => {
    return request.get(`/user/passport/auth/getUserInfo`)
}
// 退出登录
// /api/user/passport/logout
export const reqLogout = () => {
    return request.get(`/user/passport/logout`)
}


